package com.chuanye.jiguangimdemo.activitys;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.chuanye.jiguangimdemo.R;
import com.chuanye.jiguangimdemo.model.InfoModel;

public class SearchFriendInfoActivity extends BaseActivity implements View.OnClickListener {
    private static final String TAG = "SearchFriendInfoActivity";
    private Context mContext;

    private ImageView searchfriendinfo_back_iv;
    private ImageView searchfriendinfo_icon_iv;
    private TextView searchfriendinfo_nickname_tv;
    private TextView searchfriendinfo_signature_tv;
    private TextView searchfriendinfo_username_tv;

    private TextView searchfriendinfo_gender_tv;
    private TextView searchfriendinfo_birthday_tv;
    private TextView searchfriendinfo_address_tv;
    private Button searchfriendinfo_add_btn;





    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_search_friend_info);
        mContext = this;

        initView();
        initData();
    }

    private void initView() {
        //返回
        searchfriendinfo_back_iv = findViewById(R.id.searchfriendinfo_back_iv);
        searchfriendinfo_back_iv.setOnClickListener(this);
        //用户头像
        searchfriendinfo_icon_iv = findViewById(R.id.searchfriendinfo_icon_iv);
        //头像下的昵称 或备注名
        searchfriendinfo_nickname_tv = findViewById(R.id.searchfriendinfo_nickname_tv);
        //签名
        searchfriendinfo_signature_tv = findViewById(R.id.searchfriendinfo_signature_tv);
        //用户名
        searchfriendinfo_username_tv = findViewById(R.id.searchfriendinfo_username_tv);
        //性别
        searchfriendinfo_gender_tv = findViewById(R.id.searchfriendinfo_gender_tv);
        //生日
        searchfriendinfo_birthday_tv = findViewById(R.id.searchfriendinfo_birthday_tv);
        //地区
        searchfriendinfo_address_tv = findViewById(R.id.searchfriendinfo_address_tv);

        //加好友按钮
        searchfriendinfo_add_btn = findViewById(R.id.searchfriendinfo_add_btn);
        searchfriendinfo_add_btn.setOnClickListener(this);
    }

    private void initData() {
        InfoModel instance = InfoModel.getInstance();
        if (instance.getAvatar() == null) {//获取图片
            searchfriendinfo_icon_iv.setImageResource(R.drawable.rc_default_portrait);
        } else {
            searchfriendinfo_icon_iv.setImageBitmap(instance.getAvatar());
        }
        if (TextUtils.isEmpty(instance.getNickName())) {
            searchfriendinfo_nickname_tv.setText("用户名: " + instance.getUserName());
        } else {
            searchfriendinfo_nickname_tv.setText("昵称:" + instance.getNickName());
        }
        searchfriendinfo_username_tv.setText(instance.getUserName());
        searchfriendinfo_signature_tv.setText(instance.getSign());
        searchfriendinfo_gender_tv.setText(instance.getGender());
        searchfriendinfo_birthday_tv.setText(instance.getBirthday());
        searchfriendinfo_address_tv.setText(instance.getCity());
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.searchfriendinfo_back_iv://返回
                finish();
                break;
            case R.id.searchfriendinfo_add_btn: //加好友按钮
                Intent intent = new Intent(mContext, VerificationActivity.class);
                startActivity(intent);
                break;
        }
    }
}
